package com.example.xiaomaotv.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.example.xiaomaotv.R;
import com.example.xiaomaotv.entity.Mine;

import java.util.List;

public class MineAdapter extends ArrayAdapter<Mine> {
    private int resourceId;
    private List<Mine> mineData;

    public MineAdapter(@NonNull Context context, int resource, @NonNull List<Mine> objects) {
        super(context, resource, objects);
        resourceId = resource;
        mineData = objects;
    }
    @NonNull
    public View getView(int position, View convertView, @NonNull ViewGroup parent) {
        Mine list = getItem(position);
        View listView = LayoutInflater.from(getContext()).inflate(resourceId,null);
        ImageView enterImage = listView.findViewById(R.id.mine_enter);
        TextView Text = listView.findViewById(R.id.mine_text);
        ImageView icnImage = listView.findViewById(R.id.mine_icn);
        enterImage.setImageResource(list.getEnterImg());
        Text.setText(list.getText());
        icnImage.setImageResource(list.getIcnImg());
        return listView;
    }
}
